package com.ryzx.common.response;


import java.io.Serializable;

public class BapResult implements Serializable {
    private int code=200;
    private Object data;
    private String message="success";

    public BapResult(){

    }
    private BapResult(int code,String message,Object data){
        this.code=code;
        this.message=message;
        this.data=data;
    }
    private BapResult(int code,String message){
        this.code=code;
        this.message=message;
        this.data=null;
    }
    private BapResult(Object data){
        this.data=data;
    }


    public static BapResult success(){
        return new BapResult();
    }

    public static BapResult success(Object data){
        return new BapResult(data);
    }

    /** 失败数据集 */
    public static BapResult fail(BapResultCode resultCode){
        BapResult result=new BapResult();
        result.setCode(resultCode.getCode());
        result.setMessage(resultCode.getMessage());
        return result;
    }
    public static BapResult fail(BapResultCode resultCode,String message) {
        BapResult result=new BapResult();
        result.setCode(resultCode.getCode());
        result.setMessage(message);
        return result;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}

